﻿<%@ Page Title="" Language="C#" MasterPageFile="~/WithoutPermBasic.Master" AutoEventWireup="true" CodeBehind="TeamMange.aspx.cs" Inherits="StorageManage.UI.TeamMange" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
     <script type="text/javascript">
         $(function () {
             var rowData;
             var height = $("#divTotal").height();
             var master = $("#master").height();
             var content = parseFloat(height) - parseFloat(master) - 30;
             $("#tbList").css("height", content);
         });
    </script>
     <script type="text/javascript">
         $(function () {
             $("#tbList").datagrid({
                 url: '/Logic/BasicInfo.aspx?method=GetTeamUserList',
                 loadMsg: '数据加载中请稍候……',
                 pagination: true,
                 rownumbers: true,
                 fitColumns: true,
                 idField: "Id",
                 lines: true,
                 // fitColumns:true,
                 frozenColumns: [[{
                     field: 'ck', checkbox: true, width: 30
                 },
                     {
                         field: 'UserName', title: '姓名', sortable: true, width: 100, align: "center", editor: {
                             type: "validatebox",
                             options: {
                                 required: true
                             }
                         }
                     }]],
                 columns: [[
                      {
                          field: 'zjm', title: '助记码', sortable: true, width: 100, align: "center", editor: {
                              type: "validatebox",
                              options: {
                                  required: true
                              }
                          }
                      },
                     {
                         field: 'DepId', title: '班组', sortable: true, width: 100, align: "center", editor: {
                             type: "combobox",
                             options: {
                                 url: '/Logic/BasicInfo.aspx?method=GetTeam',
                                 valueField: 'value',
                                 textField: 'text',
                                 required: true
                             },
                         },
                         formatter: function (value, row, index) {
                             return row.DepName;
                         }
                     },
                              {
                                  field: 'UserState', title: '是否在职', sortable: true, width: 80, align: "center",
                                  editor: {
                                      type: "combobox",
                                      options: {
                                          data: StaticCombo.UserState,
                                          valueField: 'value',
                                          textField: 'text',
                                          required: true
                                      }
                                  },
                                  formatter: function (value, row, index) {
                                      return com.getArrayText(StaticCombo.UserState, value);
                                  }
                              },
                              {
                                  field: 'ManClerk', title: '维护人', sortable: true, width: 80, align: "center"

                              },
                               {
                                   field: 'FillDate', title: '填写日期', sortable: true, width: 150, align: "center"
                               }, {
                                   field: 'Note', title: '备注', sortable: true, width: 200, align: "center", editor: {
                                       type: "validatebox",
                                       options: {
                                           validType: ['length[0,20]']

                                       }
                                   }
                               },
                 ]],
                 singleSelect: true,
                 pageSize: 20,
                 queryParams: com.serializeSearchArray("form1"),
                 pageList: [20, 50, 100],
                 striped: true,
                 onAfterEdit: function (rowIndex, rowData, changes) {
                     if (editAction == "edit") {
                         com.ajax({
                             url: "/Logic/BasicInfo.aspx?method=EditTeamUser",
                             data: rowData,
                             success: function (data) {
                                 com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                             }
                         });
                     } else if (editAction == "add") {
                         com.ajax({
                             url: "/Logic/BasicInfo.aspx?method=AddTeamUser",
                             data: rowData,
                             success: function (data) {
                                 com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                             }
                         });
                     }
                     editRow = undefined;
                 },
                 onCancelEdit: function (rowIndex, rowData) {
                     $("#tbList").datagrid("rejectChanges");

                 }

             });
         })


    </script>
    <script>
        editRow = undefined;
        editAction = undefined;
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);

        }
        function funcAdd() {
            //添加时先判断是否有开启编辑的行，如果有则把开户编辑的那行结束编辑
            if (editRow != undefined) {

            }
            //添加时如果没有正在编辑的行，则在datagrid的第一行插入一行
            if (editRow == undefined) {
                $("#tbList").datagrid("insertRow", {
                    index: 0, // index start with 0
                    row: {

                    }
                });
                //将新插入的那一行开户编辑状态
                $("#tbList").datagrid("beginEdit", 0);
                //给当前编辑的行赋值
                editRow = 0;
                editAction = "add";
            }
        }
        function funcEdit() {
            var row = $('#tbList').datagrid('getSelected');

            if (row) {

                if (editRow != undefined) {
                }
                else {
                    var index = $("#tbList").datagrid('getRowIndex', row);
                    //  console.log(index);
                    $("#tbList").datagrid('beginEdit', index);
                    editAction = "edit";
                    editRow = index;
                    rowData = $("#tbList").datagrid("getSelected");
                }
            }
            else {
                com.message("information", "请选中一行");

            }
        }

        function funcSave() {
            $('#tbList').datagrid('endEdit', editRow);
        }
        function funcCancel() {
            $('#tbList').datagrid("cancelEdit", editRow);
            editRow = undefined;
            editAction = undefined;
        }
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceToorbar" runat="server">
    <a href="javascript:void(0)" id="btnSearch" class="easyui-linkbutton" onclick="funcSearch()"
        data-options="iconCls:'icon-search'">查询</a>
    <a href="javascript:void(0)" id="btnReload" class="easyui-linkbutton" onclick="funcReload()"
        data-options="iconCls:'icon-reload'">重置</a>
    <a href="javascript:void(0)" id="btnAdd" class="easyui-linkbutton" onclick="funcAdd()"
        data-options="iconCls:'icon-add'">添加</a>
    <a href="javascript:void(0)" id="btnEdit" class="easyui-linkbutton" onclick="funcEdit()"
        data-options="iconCls:'icon-edit'">编辑</a>
    <a href="javascript:void(0)" id="btnCancel" class="easyui-linkbutton" onclick="funcCancel()"
        data-options="iconCls:'icon-cancel'">取消编辑</a>
    <a href="javascript:void(0)" id="btnSave" class="easyui-linkbutton" onclick="funcSave()"
        data-options="iconCls:'icon-save'">保存</a>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">
        <div id="master" class="container_12" style="height: auto;float:left;">
            <form id="form1">
                <div class="grid_1 sealbl" style="text-align: right;" >
                    姓名:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="UserName" name="UserName" data-cp="co" />
                </div>
                <div class="grid_1 sealbl" style="text-align: right;">
                    班组:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text"  id="DepName" name="DepName" data-cp="co" />
                </div>
                <div class="grid_1 sealbl" style="text-align: right;">
                    在职状态:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input id="UserState" name="UserState" data-cp="=" class="easyui-combobox" value="0" data-options="valueField:'value',textField:'text',data:StaticCombo.UserState,panelHeight:'auto',editable:false" />
                </div>
            </form>
        </div>
        <table id="tbList" title="用户信息表" style="width: 100%">
        </table>
    </div>
</asp:Content>
